home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
system
/
sysprof3.zip
/
SYS_PROF.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-06-20
|
33KB
|
815 lines
;-----------------------------------------------------------------------------;
; ;
; Listing 1 ;
; ;
; NAME : SYS_PROF ;
; ;
; DATE : March 24, 1988 ;
; ;
; AUTHOR : (C) Copyright 1988 G. Kent Cobb - All Rights Reserved ;
; ;
; DESCRIPTION : ;
; This is the terminate-and-stay-resident portion of a system profiler. ;
; It installs several interrupt handlers, which monitor the occurrences ;
; and duration of a number of software interrupts. ;
; ;
;-----------------------------------------------------------------------------;
; Updated count of interrupt functions by Ralf Brown, 5/18/89 ;
;-----------------------------------------------------------------------------;
; More interrupts, speed ups, by Ralf Brown 6/18/89 ;
;-----------------------------------------------------------------------------;
; Fixed minor bug introduced 6/18, more speed tweaks on 6/20/89 ;
;-----------------------------------------------------------------------------;
;----------------------------------------------------------------------------;
; Interrupt numbers ;
;----------------------------------------------------------------------------;
TIMER_INTERRUPT EQU 1CH
TERMINATE EQU 20H
TERM_AND_STAY_RES EQU 27H
CONTROL_INTERRUPT EQU 60H
;----------------------------------------------------------------------------;
; MS-DOS functions (Interrupt 21H services) ;
;----------------------------------------------------------------------------;
DOS MACRO OP
MOV AH,DOS_&OP
INT 21H
ENDM
DOS_DISPLAY_STRING EQU 09H
DOS_SET_INT_VECTOR EQU 25H
DOS_GET_INT_VECTOR EQU 35H
;----------------------------------------------------------------------------;
; This is a list of all the interrupts that are intercepted by SYS_PROF. ;
;----------------------------------------------------------------------------;
NUMBER_OF_INTERRUPTS EQU 13
PRINT_SCREEN_INTERRUPT EQU 5H
VIDEO_INTERRUPT EQU 10H
DISK_INTERRUPT EQU 13H
COMM_INTERRUPT EQU 14H
SYS_UTIL_INTERRUPT EQU 15H
KEYBOARD_INTERRUPT EQU 16H
PRINTER_INTERRUPT EQU 17H
DOS_FUNC_INTERRUPT EQU 21H
ABS_DISK_READ_INTERRUPT EQU 25H
ABS_DISK_WRITE_INTERRUPT EQU 26H
NETWORK2A_INTERRUPT EQU 2AH
MULTIPLEX_INTERRUPT EQU 2FH
EMS_INTERRUPT EQU 67H
;----------------------------------------------------------------------------;
; These are the number of distinct services defined for each interrupt. ;
; The OCCURRENCES array contains two double words for each service, and ;
; two additional double words for each interrupt. If an interrupt is ;
; generated with a service number that is out of range, the data for it ;
; will accumulate in this additional bin. ;
;----------------------------------------------------------------------------;
PRINT_SCREEN_SERVICES EQU 0
VIDEO_SERVICES EQU 29
DISK_SERVICES EQU 29
COMM_SERVICES EQU 6
SYS_UTIL_SERVICES EQU 223
KEYBOARD_SERVICES EQU 19
PRINTER_SERVICES EQU 3
DOS_FUNC_SERVICES EQU 109
ABS_DISK_READ_SERVICES EQU 0
ABS_DISK_WRITE_SERVICES EQU 0
NETWORK2A_SERVICES EQU 7
MULTIPLEX_SERVICES EQU 206
EMS_SERVICES EQU 108
;-----------------------------------------------------------------------;
; This macro defines the handling of the intercepted interrupts. The ;
; INT_NUM parameter that the macro expects is an index into the ;
; MAX_SERVICES and OFFSETS tables. ;
; ;
; Interrupts 25H and 26H are handled in a manner which is very ;
; similar, but slightly different from the other interrupts. If this ;
; macro is invoked with a second parameter, code is included to ;
; provide the special handling that these interrupts require. ;
; ;
; INT 15h requires that the stack be undisturbed on entry to the ;
; original ISR, as parameters are passed on the stack for DESQview ;
; At this time, SPECIAL and STACK_PARMS are mutually exclusive (the ;
; stack restoration code won't work for SPECIAL) ;
;-----------------------------------------------------------------------;
PERFORM_INTERRUPT MACRO INT_NUM,MAX_SERV,SPECIAL,STACK_PARMS
IFNB <STACK_PARMS>
PRIVATE&INT_NUM DW 80 DUP (?) ; enough for 15 recursive invocations of ISR
TOP_PRIVATE&INT_NUM LABEL WORD
PRIVATE_TOP&INT_NUM DW TOP_PRIVATE&INT_NUM
ENDIF
INTERRUPT_HANDLER&INT_NUM PROC FAR
; Turn interrupts back on.
STI
; Save the existing interrupt and service numbers on the stack.
PUSH CS:WORD PTR INTERRUPT
; Push the flags onto the stack now (before we execute any instructions which
; might change them) in order to simulate an interrupt later.
PUSHF
; If accumulation is turned off, go straight to the real ISR.
CMP WORD PTR CS:WATCH,0
JE READY_FOR_INTERRUPT&INT_NUM
; Make sure the service number is valid, then turn off interrupts briefly
; while setting new INTERRUPT and SERVICE values
PUSH AX
PUSH BX ; push registers
CMP AH,MAX_SERV ; Compare current service number to max
JB SERVICE_VALID&INT_NUM ; If less, everything is OK
MOV AH,MAX_SERV ; Otherwise, set the service to the maximum #
SERVICE_VALID&INT_NUM:
CLI
MOV CS:INTERRUPT,&INT_NUM ; must be updated for INT 1Ch handler to
MOV CS:SERVICE,AH ; update proper service counter
STI
; now increment the second bin for the service
MOV BX,CS:OFFSETS[(&INT_NUM*2)] ; Get the offset into the accumulation table
MOV AL,AH ; move code for service currently being
; performed into al
XOR AH,AH ; zero out ah
SHL AX,1 ; multiply by 4 to convert number of
SHL AX,1 ; double words to number of bytes
SHL AX,1 ; multiply by 2 since there are two double
; words for each service
ADD BX,AX ; add offset to get offset of data for this
; service
ADD CS:WORD PTR [BX+4],1 ; Increment low-order word of second bin
ADC CS:WORD PTR [BX+6],0 ; if overflow, incr high-order word also
POP BX ; Restore registers
POP AX
READY_FOR_INTERRUPT&INT_NUM:
; After tabulating occurrence data, execute the real ISR
IFNB <STACK_PARMS>
POPF
PUSH BX
MOV BX,CS:PRIVATE_TOP&INT_NUM
SUB BX,10 ; will use five words on the private stack
MOV CS:PRIVATE_TOP&INT_NUM,BX
POP CS:[BX] ; remove BX from stack
POP CS:[BX+2] ; remove INTERRUPT